#!/usr/bin/env python

import sys
from itertools import groupby

if __name__ == "__main__":
    res = sorted(len(set(g[1] for g in grp)) for gene_id, grp in groupby((line.split() for line in sys.stdin), key=lambda i:i[0]))
    for locuses_num, grp in groupby(res):
        print "%4d\t%d" % (locuses_num, len(list(grp)))
